#pragma once

#ifndef DBDATABASE_H_
#define DBDATABASE_H_

#include "DBConnection.h"
#include "DBTable.h"

namespace SQLDoc
{
	class DBDatabase : public DBObject
	{
	public:
		DBDatabase(void);
		~DBDatabase(void);

		bool isActive(void);
		void ensureActive(QSqlDatabase &db);
		void deactivate(void);

		virtual int selectTables(bool refresh = false);
		virtual int tablesCount(void);

		virtual void rewriteTables(void);
		virtual void fillTables(void) = 0 { m_isValid = true; };

	protected:
		bool m_isActive;
		QList<DBTable*> m_tables;
		bool m_isValid;
		virtual void use(QSqlDatabase &db) = 0;
	};
}

#endif
